<template>
	<u-button
		:custom-style="customStyle"
		:disabled="canSubmit"
		:ripple="ripple"
		:loading="loading"
		@click="action"
	>{{btnText}}</u-button>
</template>

<script>
	export default {
		props: {
			// loading
			loading: {
				type: Boolean,
				default: false
			},
			// 是否可选
			canSubmit: {
				type: Boolean,
				default: false
			},
			// 波纹效果
			ripple: {
				type: Boolean,
				default: true
			},
			// 按钮文字
			btnText: {
				type: String,
				default: ''
			},
			// 字号
			fontSize: {
				type: Number,
				default: 28
			},
			fontWeight: {
				type: String,
				default: 'normal'
			},
			// 按钮样式 submit操作纯色 plain反色 disabled不可操作
			btnType: {
				type: String,
				default: 'submit'
			},
			propStyle: {
				type: Object,
				default: {}
			}
		},
		watch: {
			btnType () {
				this.changeStyle()
			}
		},
		computed: {
			customStyle () {
				let customStyle = {
					width: '100%',
					height: '100%',
					backgroundColor: this.propStyle.background || this.$utypeprimary,
					color:  '#FFFFFF',
					fontFamily: 'Rubik',
					fontSize: '32rpx',
					fontWeight: 'normal',
					fontWeight: '400',
					borderRadius: this.propStyle.borderRadius ||'8rpx',
					border: this.propStyle.border || `1rpx solid ${this.$utypeprimary}`,
				}
				return customStyle
			}
		},
		data() {
			return {
			}
		},
		mounted () {
			this.changeStyle()
		},
		methods: {
			action () {
				this.$emit('btnAction')
			},
			changeStyle() {
				switch(this.btnType) {
					case 'submit':
						this.customStyle.backgroundColor = this.$utypeprimary
						this.customStyle.color = '#FFFFFF'
						this.customStyle.fontSize = this.fontSize + 'rpx'
						this.customStyle.border = `1rpx solid ${this.$utypeprimary}`
						this.customStyle.fontWeight = this.fontWeight
						break
					case 'plain':
						this.customStyle.backgroundColor = '#ffffff'
						this.customStyle.color = this.$utypeprimary
						this.customStyle.fontSize = this.fontSize + 'rpx'
						this.customStyle.border = `1rpx solid ${this.$utypeprimary}`
						this.customStyle.fontWeight = this.fontWeight
						break
					case 'disabled':
						this.customStyle.backgroundColor = '#dbdbdb'
						this.customStyle.color = '#FFFFFF'
						this.customStyle.fontSize = this.fontSize + 'rpx'
						this.customStyle.border = '1rpx solid #dbdbdb'
						this.customStyle.fontWeight = this.fontWeight
						break
				}
				this.$forceUpdate()
			}
		}
	}
</script>

<style scoped lang="scss">
	.overbtn {
		width: 100%;
		height: 100%;
		.step-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
	
			image {
				width: 80rpx;
				margin-bottom: 14rpx;
				border-radius: 50%;
			}
		}
	
		.step-op1,
		.step-op2 {
			position: absolute;
			width: 116rpx;
			height: 4rpx;
			border: 1rpx dashed #de6436;
			opacity: 0.3;
		}
	
		.step-op1 {
			top: 40rpx;
			left: 186rpx;
		}
	
		.step-op2 {
			top: 40rpx;
			left: 446rpx;
		}
	}
</style>
